package com.longqin.business.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.longqin.business.entity.BusExamine;
import com.longqin.business.service.IBusExamineService;
import com.longqin.business.util.ResponseData;
import com.longqin.business.util.ResponseEnum;

import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author longqin
 * @since 2025-01-07
 */
@RestController
@RequestMapping("/examine")
public class BusExamineController {
	
	@Autowired
	IBusExamineService busExamineService;

	/**
	 * @Description 根据工作实例id获取审批数据集合
	 * @Author longqin
	 * @Time: 2025年1月7日
	 */
	@ApiOperation(value = "根据工作实例id获取审批数据集合", httpMethod = "GET")
	@ApiImplicitParams({ 
		@ApiImplicitParam(name = "workId", value = "工作实例id", required = true, dataType = "int")
	})
	@ApiResponses({ @ApiResponse(code = 1, message = "查询成功"), @ApiResponse(code = 0, message = "查询失败"), @ApiResponse(code = 3, message = "参数错误") })
	@GetMapping("/getByWorkId")
	public ResponseData getByWorkId(Integer workId) {
		if (null == workId) {
			return new ResponseData(ResponseEnum.BADPARAM.getCode(), "参数错误");
		}
		List<BusExamine> examines = busExamineService.getByWorkId(workId);
		if (null != examines){
			return new ResponseData(ResponseEnum.SUCCESS.getCode(), "查询成功", examines);
		}
		return new ResponseData(ResponseEnum.ERROR.getCode(), "查询失败");
	}
}
